﻿using Unity.Burst;
using Unity.Entities;


public partial struct InstantiateGameObjectSystem : ISystem
{
    [BurstCompile]
    public void OnCreate(ref SystemState state)
    {
        state.RequireForUpdate<BattleSceneTag>();
    }

    public void OnUpdate(ref SystemState state)
    {

        //敌人 遍历所有instantiateGameObjectTag组件被启用的敌人
        foreach (var ( enemyData, transAsyncInfo, instantiateGameObjectTag) in
                 SystemAPI.Query<EnemyData, RefRW<TransAsyncInfo>, EnabledRefRW<InstantiateGameObjectTag>>())
        {
            var go = GameController.Instance.GetEnemyGo(enemyData.Id, enemyData.EcsId);
            transAsyncInfo.ValueRW.Trans = go.transform;
        
            instantiateGameObjectTag.ValueRW = false;
        }

    }

}